/**
 * Copyright (C) 2010 Cloudfarming <info@cloudfarming.nl>
 *
 * Licensed under the Eclipse Public License - v 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.eclipse.org/legal/epl-v10.html
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package nl.cloudfarming.client.geoviewer;

import org.openide.nodes.Node;
import org.openide.util.Lookup;
import org.openide.util.lookup.AbstractLookup;
import org.openide.util.lookup.InstanceContent;

/**
 *
 * @author Timon Veenstra
 */
public interface MapController {


    /**
     * true if the controller is currently actively controlling a map
     * 
     * @return 
     */
    boolean isActive();
    /**
     * Refresh the layers content display on the map
     * 
     * @param layer 
     */
    void refreshLayer(Layer layer);

    /**
     * Get the layer information for a layer in a map
     *
     * @param layer
     * @return
     */
    LayerInfo getLayerInfo(Layer layer);

    /**
     * ghet the current present for a map
     * DO NOT USE
     *
     * @return Preset
     * @deprecated  preset system needs refactoring
     */
    @Deprecated
    Preset getCurrentPreset();

    /**
     * name of the map
     * must be unique for each instance
     * 
     * @return
     */
    String getMapName();

    /**
     * Zoom the map to a layer object
     * 
     * @param layerObject
     * @param layer
     */
    void zoomToObject(LayerObject layerObject, Layer layer);

    /**
     * add a layer to the map
     * 
     * @param layer
     */
//    void addLayer(Layer<LayerObject<?>> layer);
//    void selectObjectInLayer(Layer<LayerObject<?>> layer, LayerObject<?> layerObjectNode);
    
    public static final class Registry  {

        private Registry(){}
        
        private static final InstanceContent CONTENT = new InstanceContent();
        private static final AbstractLookup LOOKUP = new AbstractLookup(CONTENT);

        public static Lookup getLookup() {
            return LOOKUP;
        }

        public static Lookup.Provider getProvider(){
            return new Lookup.Provider() {

                @Override
                public Lookup getLookup() {
                    return LOOKUP;
                }
            };
        }

        public static void addMapController(MapController mapController) {
            CONTENT.add(mapController);
        }

        public static void removeMapController(MapController mapController) {
            CONTENT.remove(mapController);
        }
    }
}
